/*
 * Copyright (c) 2002-2007, Mairie de Paris
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 *  1. Redistributions of source code must retain the above copyright notice
 *     and the following disclaimer.
 *
 *  2. Redistributions in binary form must reproduce the above copyright notice
 *     and the following disclaimer in the documentation and/or other materials
 *     provided with the distribution.
 *
 *  3. Neither the name of 'Mairie de Paris' nor 'Lutece' nor the names of its
 *     contributors may be used to endorse or promote products derived from
 *     this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 *
 * License 1.0
 */
package fr.paris.lutece.plugins.customisation.business.portlet;

import fr.paris.lutece.portal.business.portlet.Portlet;

import java.sql.Timestamp;

import java.util.List;


/**
 * IPersonalPortletDAO Interface
 */
public interface IPersonalPortletDAO
{
    /**
     * Insert a new record in the table
     *
     * @param portlet the personal portlet to insert in the database
     */
    void insert( PersonalPortlet portlet );

    /**
     * Delete a record from the table
     *
     * @param portlet the personal portlet to be deleted
     */
    void delete( PersonalPortlet portlet );
    
    /**
     * Delete the records of a specific tab from the table
     *
     * @param portlet the portlet to delete in the database
     */
    void deleteAllPortletByTab( PersonalPortlet portlet );

    /**
     * Update the record in the table
     *
     * @param portlet the portlet to update in the database
     */
    void store( PersonalPortlet portlet );

    /**
     * Load the data of a personal portlet in a specific tab from the database
     *
     * @param nIdPortlet the portlet identifier
     * @param nIdTab the tab identifier
     * @return the object PersonalPortlet initialized with the data of the database
     */
    PersonalPortlet load( int nIdPortlet, int nIdTab );

    /**
     * Returns a list of portlets according the user identifier ans the tab identifier
     *
     * @param strUserName the user identifier
     * @param nIdTab the tab identifier
     * @return the user's portlets in form of Collection
     */
    List<PersonalPortlet> selectAllPortletByTab( String strUserName, int nIdTab );

    /**
     * Returns the count of a specified portlet
     *
     * @param nIdPortlet the portlet identifier
     * @return the count of a specified portlet
     */
    int selectCountPortlet( int nIdPortlet );

    /**
     * Returns the list of all portlets used in the front office
     *
     * @return the list of all portlets used in the front office
     */
    List<PersonalPortlet> selectAllPortlets(  );

    /**
     * Returns the count of a specified portlet by the different user
     *
     * @param nIdPortlet the portlet identifier
     * @return the count of a specified portlet by the different user
     */
    int selectCountPortletByUser( int nIdPortlet );

    /**
     * Returns the date of the last add for a portlet
     *
     * @param nIdPortlet the portlet identifier
     * @return the date of the last add for a portlet
     */
    Timestamp selectLastAddition( int nIdPortlet );

    /**
     * Deletes the portlet specified in all the tabs of users' site
     *
     * @param nPortletId the portlet identifier
     */
    void deletePortletFromAllTab( int nPortletId );

    /**
     * Returns if the portlet specified exist or not
     *
     * @param nIdPortlet the portlet identifier
     * @return if the portlet specified exist or not
     */
    boolean checkPortlet( int nIdPortlet );

    /**
     * Update the records in the table
     *
     * @param portlet the portlet to update in the database
     */
    void store( Portlet portlet );
    
    /**
     * Returns the list of published portlets but not displayed on any page
     *
     * @param the identifier of the tab
     * @return the undisplayed portlets in form of Collection
     */
    List<PersonalPortlet> selectAllUndisplayedPortlet( int nIdTab);

}
